#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Changing language on the fly
"""

import gettext

import web

from config import *

def switch_language():
    # Load the specified language
    mylang = web.cookies(mylang = lang)
    language = [mylang.mylang]
    gettext.translation('piggymail', locale_dir, languages = language).install(True)

    # Render template with the specified language
    tglobals = {'_': _,
                'session': web.ctx.session
                }
    pages = web.template.render('app/views',cache = cache,base = 'base',globals = tglobals)

    return pages

